<template>
	<!--两栏-->
	<view class="fboxRow Xcenter Ycenter column-box font20" :class="className" v-if="list.length">
		<view class="flex1 item" v-for="(item, index) in list" :key="index">
			<image class="radius8 img" :src="item.url" mode="aspectFit" @tap="pageTo(item)">
			</image>
		</view>
	</view>
</template>

<script>
	import { bksFunctionInfo } from '@/api/bks.index.js'
	import { bannerStatistical } from '@/api/bks.login.js'
	import { getRequest, parseQueryStringt } from '@/static/js/common.js';
	export default {
		props: {
			className: {
				type: String,
				default: ''
			},
			code: {
				type: String,
				default: ''
			},
			prams: {
				type: [String, Object],
				default: ''
			},
		},
		data() {
			return {
				list: []
			}
		},
		mounted() {
			this.init()
		},
		methods: {
			// 初始化
			init() {
				bksFunctionInfo({
					identify: this.code
				}).then(res => {
					if (res.data) {
						this.list = res.data.list || null
					} else {
						this.list = null
					}
				})
			},
			// 跳转
			pageTo(e) {
				const { jumpUrl } = e
				if (jumpUrl.indexOf('tips:') != -1) {
					let title = jumpUrl.split(':')[1]
					uni.showToast({
						title,
						icon: 'none'
					})
				} else if (jumpUrl) {
					const { prams } = this
					const newUrl = jumpUrl.replace('/pages/', '/bks/')
					if (typeof(prams) == 'string') {
						const url = newUrl + prams
						this.$pageTo(url)
					} else {
						this.$pageTo(newUrl, prams)
					}
					const bw_bks_user = uni.getStorageSync('bw_bks_user') || ''
					const query = parseQueryStringt(jumpUrl)
					bannerStatistical({
						adId: e.id,
						linkId: query.id,
						memberId: bw_bks_user.memberId
					})
				} else {
					console.log('path空不能跳转')
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	/* 快捷入口:学习资料,成绩查询 */
	.column-box {
		margin: 0 auto;
		padding: 20rpx 0 0;
		width: 690rpx;
		font-size: 20rpx;
		color: #925800;
	}

	.column-box .img {
		position: relative;
		width: 335rpx;
		height: 136rpx;
		overflow: hidden;
		z-index: 0;
	}

	.column-box .flex1 {
		position: relative;
	}

	.column-box .flex1:first-child {
		margin-right: 20rpx;
	}
</style>